﻿using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Xml.Schema;

namespace ScormModel
{
    [Serializable()]
    public class RuleCondition
    {
        //referencedObjective
        //measureThreshold
        //operator
        private string _condition;
        private string _operator;
        private string _measureThreshold;
        private string _referencedObjective;
         [NonSerialized]
        private XmlNode _ruleConditionContent;
        [XmlAttribute("condition")]
        public string Condition
        {
            get { return this._condition; }
            set { this._condition = value; }
        }
        [XmlAttribute("operator")]
        public string Operator
        {
            get { return this._operator; }
            set { this._operator = value; }
        }
        
        [XmlIgnoreAttribute]
        public XmlNode RuleConditionContent
        {
            get { return this._ruleConditionContent; }
            set { this._ruleConditionContent = value; }
        }
        public void buildRuleCondition()
        {
            XmlAttributeCollection attList = _ruleConditionContent.Attributes;
            for (int i = 0; i < attList.Count; i++)
            {
                if (attList[i].Name == "condition")
                {
                    _condition = attList[i].Value;
                }
                if (attList[i].Name == "operator")
                {
                    _operator = attList[i].Value;
                }
                if (attList[i].Name == "referencedObjective")
                {
                    _referencedObjective = attList[i].Value;
                }
                if (attList[i].Name == "measureThreshold")
                {
                    _measureThreshold = attList[i].Value;
                }
            }
        }
    }
}
